home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / RADOIMPL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-30  |  5.2 KB  |  203 lines

  1. unit RadoImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelLib;
  8.  
  9. type
  10.   TRadioButtonX = class(TActiveXControl, IRadioButtonX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TRadioButton;
  14.     FEvents: IRadioButtonXEvents;
  15.     procedure ClickEvent(Sender: TObject);
  16.     procedure DblClickEvent(Sender: TObject);
  17.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  18.   protected
  19.     { Protected declarations }
  20.     procedure InitializeControl; override;
  21.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  22.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  23.     function Get_Caption: WideString; safecall;
  24.     function Get_Checked: WordBool; safecall;
  25.     function Get_Color: TColor; safecall;
  26.     function Get_Ctl3D: WordBool; safecall;
  27.     function Get_Cursor: Smallint; safecall;
  28.     function Get_DragCursor: Smallint; safecall;
  29.     function Get_Enabled: WordBool; safecall;
  30.     function Get_Font: Font; safecall;
  31.     function Get_ParentColor: WordBool; safecall;
  32.     function Get_Visible: WordBool; safecall;
  33.     procedure AboutBox; safecall;
  34.     procedure Set_Caption(const Value: WideString); safecall;
  35.     procedure Set_Checked(Value: WordBool); safecall;
  36.     procedure Set_Color(Value: TColor); safecall;
  37.     procedure Set_Ctl3D(Value: WordBool); safecall;
  38.     procedure Set_Cursor(Value: Smallint); safecall;
  39.     procedure Set_DragCursor(Value: Smallint); safecall;
  40.     procedure Set_Enabled(Value: WordBool); safecall;
  41.     procedure Set_Font(const Value: Font); safecall;
  42.     procedure Set_ParentColor(Value: WordBool); safecall;
  43.     procedure Set_Visible(Value: WordBool); safecall;
  44.   end;
  45.  
  46. implementation
  47. uses radioPg;
  48. { TRadioButtonX }
  49.  
  50. procedure TRadioButtonX.InitializeControl;
  51. begin
  52.   FDelphiControl := Control as TRadioButton;
  53.   FDelphiControl.OnClick := ClickEvent;
  54.   FDelphiControl.OnDblClick := DblClickEvent;
  55.   FDelphiControl.OnKeyPress := KeyPressEvent;
  56. end;
  57.  
  58. procedure TRadioButtonX.EventSinkChanged(const EventSink: IUnknown);
  59. begin
  60.   FEvents := EventSink as IRadioButtonXEvents;
  61. end;
  62.  
  63. procedure TRadioButtonX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  64. begin
  65.   { Define property pages here.  Property pages are defined by calling
  66.     DefinePropertyPage with the class id of the page.  For example,
  67.       DefinePropertyPage(Class_RadioButtonXPage); }
  68. end;
  69.  
  70. function TRadioButtonX.Get_Caption: WideString;
  71. begin
  72.   Result := WideString(FDelphiControl.Caption);
  73. end;
  74.  
  75. function TRadioButtonX.Get_Checked: WordBool;
  76. begin
  77.   Result := FDelphiControl.Checked;
  78. end;
  79.  
  80. function TRadioButtonX.Get_Color: TColor;
  81. begin
  82.   Result := FDelphiControl.Color;
  83. end;
  84.  
  85. function TRadioButtonX.Get_Ctl3D: WordBool;
  86. begin
  87.   Result := FDelphiControl.Ctl3D;
  88. end;
  89.  
  90. function TRadioButtonX.Get_Cursor: Smallint;
  91. begin
  92.   Result := Smallint(FDelphiControl.Cursor);
  93. end;
  94.  
  95. function TRadioButtonX.Get_DragCursor: Smallint;
  96. begin
  97.   Result := Smallint(FDelphiControl.DragCursor);
  98. end;
  99.  
  100. function TRadioButtonX.Get_Enabled: WordBool;
  101. begin
  102.   Result := FDelphiControl.Enabled;
  103. end;
  104.  
  105. function TRadioButtonX.Get_Font: Font;
  106. begin
  107.   GetOleFont(FDelphiControl.Font, Result);
  108. end;
  109.  
  110. function TRadioButtonX.Get_ParentColor: WordBool;
  111. begin
  112.   Result := FDelphiControl.ParentColor;
  113. end;
  114.  
  115. function TRadioButtonX.Get_Visible: WordBool;
  116. begin
  117.   Result := FDelphiControl.Visible;
  118. end;
  119.  
  120. procedure TRadioButtonX.AboutBox;
  121. begin
  122.   ShowRadioButtonXAbout;
  123. end;
  124.  
  125. procedure TRadioButtonX.Set_Caption(const Value: WideString);
  126. begin
  127.   FDelphiControl.Caption := TCaption(Value);
  128. end;
  129.  
  130. procedure TRadioButtonX.Set_Checked(Value: WordBool);
  131. begin
  132.   FDelphiControl.Checked := Value;
  133. end;
  134.  
  135. procedure TRadioButtonX.Set_Color(Value: TColor);
  136. begin
  137.   FDelphiControl.Color := Value;
  138. end;
  139.  
  140. procedure TRadioButtonX.Set_Ctl3D(Value: WordBool);
  141. begin
  142.   FDelphiControl.Ctl3D := Value;
  143. end;
  144.  
  145. procedure TRadioButtonX.Set_Cursor(Value: Smallint);
  146. begin
  147.   FDelphiControl.Cursor := TCursor(Value);
  148. end;
  149.  
  150. procedure TRadioButtonX.Set_DragCursor(Value: Smallint);
  151. begin
  152.   FDelphiControl.DragCursor := TCursor(Value);
  153. end;
  154.  
  155. procedure TRadioButtonX.Set_Enabled(Value: WordBool);
  156. begin
  157.   FDelphiControl.Enabled := Value;
  158. end;
  159.  
  160. procedure TRadioButtonX.Set_Font(const Value: Font);
  161. begin
  162.   SetOleFont(FDelphiControl.Font, Value);
  163. end;
  164.  
  165. procedure TRadioButtonX.Set_ParentColor(Value: WordBool);
  166. begin
  167.   FDelphiControl.ParentColor := Value;
  168. end;
  169.  
  170. procedure TRadioButtonX.Set_Visible(Value: WordBool);
  171. begin
  172.   FDelphiControl.Visible := Value;
  173. end;
  174.  
  175. procedure TRadioButtonX.ClickEvent(Sender: TObject);
  176. begin
  177.   if FEvents <> nil then FEvents.OnClick;
  178. end;
  179.  
  180. procedure TRadioButtonX.DblClickEvent(Sender: TObject);
  181. begin
  182.   if FEvents <> nil then FEvents.OnDblClick;
  183. end;
  184.  
  185. procedure TRadioButtonX.KeyPressEvent(Sender: TObject; var Key: Char);
  186. var
  187.   TempKey: Smallint;
  188. begin
  189.   TempKey := Smallint(Key);
  190.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  191.   Key := Char(TempKey);
  192. end;
  193.  
  194. initialization
  195.   TActiveXControlFactory.Create(
  196.     ComServer,
  197.     TRadioButtonX,
  198.     TRadioButton,
  199.     Class_RadioButtonX,
  200.     18,
  201.     '{5A5659B2-7975-11D0-BE02-00A024D1875C}');
  202. end.
  203.